//
//  LoadingUIViewController.m
//  VietNews
//
//  Created by Nguyen .a.Hph on 8/4/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import "LoadingUIViewController.h"

@interface LoadingUIViewController ()

@end

@implementation LoadingUIViewController
@synthesize loadingIndicator;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

/*
- (void)loadView
{
    // If you create your views manually, you MUST override this method and use it to create your views.
    // If you use Interface Builder to create your views, then you must NOT override this method.
}
*/
- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
    // Loading Indicator
    LoadingIndicator *theLoadingIndicator = [[LoadingIndicator alloc] init];
    theLoadingIndicator.hidden = YES;   // Hidden by default
    self.loadingIndicator = theLoadingIndicator;
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
	if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
        return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
    } else {
        return YES;
    }
}

#pragma mark - LoadingIndicator
- (void)showLoadingIndicator:(NSString *)theMessage{
    @autoreleasepool {
        [self.loadingIndicator performSelectorOnMainThread:@selector(show:) withObject:theMessage waitUntilDone:NO];
    }
}
- (void)hideLoadingIndicator{
    @autoreleasepool {
        [self.loadingIndicator performSelectorOnMainThread:@selector(hide) withObject:nil waitUntilDone:NO];
    }
}

@end
